import { request_post, request_get, request_put, request_delete } from 'services/common/request';
import pathToRegexp from 'path-to-regexp';
let toPathGroup = pathToRegexp.compile('/api/data_articles/groups/:id');
/**
 * 获取角色列表
 * @param {Object} data
 * @param {String} data.name - 选填 名称
 * @param {String} data.pageStart
 * @param {String} data.pageOffset
 * @param {String} data.pageNum
 */
export function getList(data = {}) {
	return request_get('/role/roleList', data);
}

/**
 * 获取角色
 * @param {Object} data
 * @param {String} data.name - 选填 名称
 * @param {String} data.interfaceIds
 * @param {String} data.name
 */
export async function save(data = {}) {
	if (data.id) {
		return request_put('/role/chmodRolePermission', data);
	}
	return request_post('/role/addRole', data);
}

/**
 * 获取详情
 * @param {Object} data
 * @param {String} data.name - 选填 名称
 * @param {String} data.username
 * @param {String} data.password
 */
export function detail(data = {}) {
	return request_get('/interface/menuInterfaceList', data);
}

/**
 * 获取详情
 * @param {Object} data
 * @param {String} data.name - 选填 名称
 * @param {String} data.username
 * @param {String} data.password
 */
export function del(data = {}) {
	return request_delete('/role/delRole', data);
}
